package com.yxy.mapper;

import com.yxy.pojo.entity.User;
import com.yxy.pojo.vo.UserVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    @Select("select * from user where user_name = #{username}")
    User selectByUserName(String username);

    /**
     * 根据用户id查询用户
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId}")
    User getById(int userId);

    /**
     * 新增用户
     * @param user
     */
    void insert(User user);

    /**
     * 用户登录
     * @param user
     * @return
     */
    @Select("select * from user where user_name = #{username} and user_pwd = #{password}")
    UserVO login(User user);

    /**
     * 更新用户
     * @param user
     */
    void update(User user);

    /**
     * 校验密码
     * @param user
     * @return
     */
    @Select("select * from user where id = #{id} and user_pwd = #{password}")
    Boolean checkPwd(User user);
}
